﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using RestNews.Util.DigestAuthentication;
using RestNews.Util.CustomFilters;

namespace RestNews
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            //Add authentication handler
            config.MessageHandlers.Add(new AuthenticationHandler());

            //Add default authorization attribute
            config.Filters.Add(new AuthorizeAttribute());

            //Add unhandled error logger
            config.Filters.Add(new UnhandledExceptionFilter());
        }
    }
}
